package com.atguigu.cloud.controller;

import com.atguigu.cloud.service.AccountService;
import com.atguigu.cloud.utils.ResultData;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: huahua
 * @Date: 2024/6/26 0026
 * @Time: 21:32
 * @Description:
 */
@RestController
@Slf4j
public class AccountController {
    @Resource
    private AccountService accountService;

    @PostMapping("/account/decrease")
    ResultData decrease(@RequestParam("userId") Long userId, @RequestParam("money") Long money){
        boolean flag = accountService.decrease(userId,money);


        return flag ? ResultData.success(ResultData.success("ok")) : ResultData.fail("2001","没有余额");
    }
}
